package com.um.jdy.tcp.netty;

import io.netty.channel.ChannelHandlerContext;
import io.netty.util.AttributeKey;
import lombok.experimental.UtilityClass;

/**
 * @author 甘天伟
 * @since 2024/7/30
 * 版权所有 广州优匠科技有限公司
 */
@UtilityClass
public class NettyChannelAttrs {

    public static final AttributeKey<String> DEVICE_NAME = AttributeKey.valueOf("deviceName");

    public String getDeviceName(ChannelHandlerContext ctx) {
        return ctx.channel().attr(DEVICE_NAME).get();
    }

    public void setDeviceName(ChannelHandlerContext ctx, String deviceName) {
        ctx.channel().attr(DEVICE_NAME).set(deviceName);
    }

}
